﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Utils.Physics2D.Collision;

namespace Utils.Physics2D.Objects
{
    public class PhysicsObject
    {
        protected Vector2 oldPos;
        protected Vector2 pos;
        protected Vector2 vel;
        protected float radius;
        protected CollisionHandler collisionHandler;

        public virtual Vector2 OldPos { get { return oldPos; } set { oldPos = value; } }
        public virtual Vector2 Pos { get { return pos; } set { pos = value; } }
        public virtual Vector2 Vel { get { return vel; } set { vel = value; } }
        public virtual float Radius { get { return radius; } set { radius = value; } }
        public CollisionHandler CollisionHandler { get { return collisionHandler; } set { collisionHandler = value; } }

        public PhysicsObject()
        {
            this.oldPos = this.pos = Vector2.Zero;
            this.vel = Vector2.Zero;
            this.radius = 0;
            collisionHandler = NullCollider.DEFAULT;
        }

        public PhysicsObject(Vector2 pos, Vector2 vel, float radius)
        {
            this.oldPos = this.pos = pos;
            this.vel = vel;
            this.radius = radius;
            collisionHandler = NullCollider.DEFAULT;
        }

        public PhysicsObject(Vector2 pos, Vector2 vel, float radius, CollisionHandler collisionHandler)
        {
            this.pos = pos;
            this.vel = vel;
            this.radius = radius;
            this.collisionHandler = collisionHandler;
        }

        public virtual void Update(float dTime)
        {
            oldPos = pos;
            pos += vel * dTime;
        }
    }
}